package io.mft.runtime.invoker;

import org.springframework.stereotype.Component;

import io.mft.commons.function.FunctionActionRequest;
import io.mft.commons.function.response.FunctionResponse;
import io.mft.dev.base.ApiInvoker;
import io.mft.runtime.MFTApiExecutor;
import io.mft.runtime.function.ApiFunctionRequest;
import io.mft.runtime.function.ApiFunctionResponse;
@Component
public class ApiInvokerImpl implements ApiInvoker {

	@Override
	public FunctionResponse invoke(String apiKey, FunctionActionRequest request) {
		ApiFunctionRequest apiFunctionRequest=new ApiFunctionRequest(request.getRequestValue());
		ApiFunctionResponse apiFunctionResponse=MFTApiExecutor.getInstance().execute(apiKey, apiFunctionRequest);
		FunctionResponse response=new FunctionResponse(apiFunctionResponse);
		return response;
	}

}
